home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / gengui2.lha / GenGui2 / Examples / test.c < prev    next >
C/C++ Source or Header  |  1995-02-16  |  3KB  |  96 lines

  1.  
  2. #include <stdlib.h>
  3. #include <proto/intuition.h>
  4. #include <intuition/intuition.h>
  5. #include <proto/exec.h>
  6. #include <proto/graphics.h>
  7. #include <graphics/text.h>
  8. #include <stdio.h>
  9.  
  10. #ifndef GUINAME
  11. #include "test.h"
  12. #else
  13. #include GUINAME
  14. #endif
  15.  
  16. struct IntuitionBase *IntuitionBase;
  17. struct GfxBase *GfxBase;
  18. struct Library *GadToolsBase;
  19. struct Library *UtilityBase;
  20. struct Window *win;
  21. struct TextFont *font=NULL;
  22.  
  23. void quit(char *e)
  24. {
  25.    if(e) fprintf(stderr,"%s\n",e);
  26.  
  27.    if(font) CloseFont(font); /* Important !!! */
  28.    if(win) CloseWindow(win);
  29.    if(UtilityBase) CloseLibrary(UtilityBase);
  30.    if(GadToolsBase) CloseLibrary(GadToolsBase);
  31.    if(GfxBase) CloseLibrary((struct Library *)GfxBase);
  32.    if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
  33.  
  34.    if(e) exit(EXIT_FAILURE);
  35.    exit(EXIT_SUCCESS);
  36. }
  37.  
  38. main()
  39. {
  40.    struct IntuiMessage *msg;
  41.    int run=1;
  42.  
  43.    if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",36)))
  44.       quit("No intuition.library V36");
  45.  
  46.    if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",36)))
  47.       quit("No graphics.library V36");
  48.  
  49.    if(!(GadToolsBase=OpenLibrary("gadtools.library",36)))
  50.       quit("No gadtools.library V36");
  51.  
  52.    if(!(UtilityBase=OpenLibrary("utility.library",36)))
  53.       quit("No utility.library V36");
  54.  
  55.    if(!(win=OpenWindowTags(NULL,
  56.          WA_Left,160,WA_Top,20,
  57.          WA_Width,320,WA_Height,200,
  58.          WA_Title,TITLE,
  59.          WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  60.                   IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW|IDCMP_SIZEVERIFY,
  61.          WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  62.                      |WFLG_SIMPLE_REFRESH
  63.                      |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  64.          WA_MinWidth,0,WA_MinHeight,0,
  65.          WA_MaxWidth,-1,WA_MaxHeight,-1,
  66.          TAG_DONE ))) quit("Cannot open window");
  67.  
  68.    if(GG_SmartRenderGui(win,&TestPro,&font)) quit("Cannot render GUI");
  69.  
  70.    while(run) {
  71.       WaitPort(win->UserPort);
  72.       while(msg=GG_GetIMsg(win->UserPort)) {
  73.          switch(msg->Class) {
  74.             case IDCMP_CLOSEWINDOW: run--;
  75.                                     break;
  76.             case IDCMP_NEWSIZE:     GG_ResizeGui(&TestPro);
  77.                                     break;
  78.             case IDCMP_SIZEVERIFY:  GG_BeginResizeGui(&TestPro);
  79.                                     break;
  80.             case IDCMP_REFRESHWINDOW:
  81.                                     GG_RefreshGui(&TestPro);
  82.                                     break;
  83.             case IDCMP_GADGETUP:
  84.                                     break;
  85.          }
  86.          GG_ReplyIMsg(msg);
  87.       }
  88.    }
  89.    GG_FreeGui(&TestPro);
  90.  
  91.    quit(NULL);
  92. }
  93.  
  94.  
  95.  
  96.